/**
* *****************************************************************************
 * @file branch.c
 *
 * @brief Branch source file for the project
* *****************************************************************************
 */

/* include -------------------------------------------------------------------- */
#include "../Inc/branch.h"
#include <stdlib.h>


/* Function prototype -------------------------------------------------------- */
/**
 * @brief Add a new student to the system.
 * 
 * @param student Pointer to the student structure array.
 * @param studentnumber Pointer to the number of students in the system.
 * 
 * @return void
 */
void AddStudent(StudeStudentStructurent** student, uint32_t* studentnumber) {
	(*studentnumber)++;
	*student = (StudeStudentStructurent*)realloc(*student, (*studentnumber) * sizeof(StudeStudentStructurent));
	printf("id: ");
	scanf("%15s", (*student)[(*studentnumber) - 1].id);
	printf("name: ");
	scanf("%15s", (*student)[(*studentnumber) - 1].name);
	printf("gender: ");
	scanf("%7s", (*student)[(*studentnumber) - 1].gender);
	printf("age: ");
	scanf("%d", &(*student)[(*studentnumber) - 1].age);
	printf("Student %s %s has been added.\n", (*student)[(*studentnumber) - 1].id, (*student)[(*studentnumber) - 1].name);
}

/**
 * @brief Delete a student from the system.
 * 
 * @param student Pointer to the student structure array.
 * @param studentnumber Pointer to the number of students in the system.
 * 
 * @return void
 */
void DisplayAllStudents(StudeStudentStructurent* student, uint32_t studentnumber) {
	printf("Current number of students in the system: %d\n", studentnumber);
	for (size_t i = 0; i < studentnumber; i++) {
		printf("%d. ", i + 1);
		printf("id: %s\t", student[i].id);
		printf("name: %s\t", student[i].name);
		printf("gender: %s\t", student[i].gender);
		printf("age: %d\n", student[i].age);
	}
	printf("\nAll student information has been loaded.\n");
}